<layout name="Layout/layout" />
<div class="row">
	<div class="col-lg-12">
		<h1 class="page-header">用户</h1>
	</div>
	<!-- /.col-lg-12 -->
</div>
<!-- /.row -->
<div class="row">
	<div class="col-lg-12">
		<div class="panel panel-default">
			<div class="panel-heading">
				用户列表
			</div>
			<!-- /.panel-heading -->
			<div class="panel-body">
			<?php
				$head = array(
					'id'	=>	array('ID','doNothing'),
					'username'	=>	array('用户名','doNothing'),
					'name'	=>	array('姓名','doNothing'),
					'role_id'	=>	array('角色','getRoleById')
				);
			?>
			{:W('Table/tableWithFunction', array($head, $userlist, C('OP_TYPE.OP_RESET')))}
			</div>
			<!-- /.panel-body -->
		</div>
		<!-- /.panel -->
	</div>
	<!-- /.col-lg-12 -->
</div>
<!-- Modal -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        <h4 class="modal-title" id="myModalLabel">重置成功</h4>
      </div>
      <div id="message" class="modal-body">
        密码已经重置成功！
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
      </div>
    </div>
  </div>
</div>
<script>
	window.onload = function(){
		$('.btn-reset').click(function(){
			var uid = $(this).parent().siblings().first().text();
			console.log(uid);
			$.post("{:U('Admin/User/resetPassword')}",
			{
				uid: uid,
			},
			function(data,state){
				if(data.opstatus == 'success'){
					$('#myModal').modal();
				}else{
					$('#message').text('密码重置失败，请稍后重试！');
					$('#myModal').modal();
				}
			});
		});
	}
</script>
